<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Art extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function override(){
		header('Location: /');
	}
	
	public function index()
	{
		$this->load->model('artmodel');
		$this->load->library('session');
		//var_dump($_COOKIE);die();
		if(isset($_COOKIE['userid']) && $_COOKIE['userid']!=''){
		$username=$this->artmodel->userLogin($_COOKIE);
		$displayData['username'] = $username;
		if (isset($username[0]['email']) && $username[0]['email']!=''){
			$newdata = array(
					'user_id'  => $username[0]['user_id'],
					'name'=>$username[0]['name'],
					'gender'=>$username[0]['gender'],
					'pssword'=>$username[0]['pssword'],
					'email'  => $username[0]['email'],
					'logged_in' => TRUE
			);
			$this->session->set_userdata($newdata);
			$sessionData = $this->session->all_userdata();
		}
		}
		$currentCity = array( 'city' => 'Delhi');
		$this->session->set_userdata($currentCity);
		$sessionData = $this->session->all_userdata();
		$displayData['sessionData'] = $sessionData;
        if (isset($sessionData['logged_in']) && $sessionData['logged_in']) {
        	if(isset($sessionData['name']) && $sessionData['name']!=''){
         		$displayData['name'] = $sessionData['name'];  
        	}
        }
            $artistName = $this->artmodel->getAllArtistNane();
            $displayData['artistName'] = $artistName;
            $themeName = $this->artmodel->getAllTheme();
            $displayData['themeName'] = $themeName;
            $mediumName = $this->artmodel->getAllMedium();
            $displayData['mediumName'] = $mediumName;
            $catagoriesName = $this->artmodel->getAllCatagories();
            $displayData['catagoriesName'] = $catagoriesName;
            $this->load->view('art_home', $displayData); 
	}
	
	public function joinNow()
	 {
		$this->load->model('artmodel');
		$this->load->library('session');
		$this->load->helper('captcha');
		$data = $this->setCaptcha();
		$displayData['data'] = $data;
		//var_dump($data);die();
		$sessionData = $this->session->all_userdata();
		$displayData['sessionData'] = $sessionData;
		$cUrl = $this->curURL();
		$displayData['curUrl'] = substr(strrchr($cUrl, "/"), 1);
                $artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
	  	$this->load->view('userRegister/joinus', $displayData);
		
	 }
	 
	 public function reloadCaptcha()
	 {
	 	$this->load->library('session');
	 	$this->load->helper('captcha');
	 	$data = $this->setCaptcha();
	 	$displayData['data'] = $data;
	 	$this->load->view('common/captcha', $displayData);
	 }
	 
	 function setCaptcha()
	 {
	 	$this->load->helper('captcha');
	 	$this->load->helper('url');
	 	$vals = array(
	 			'img_path'          => './public/captcha/',
	 			'img_url'           => base_url().'/public/captcha/',
	 			'expiration'        => 3600,// one hour
	 			'font_path'     => './system/fonts/texb.ttf',
	 			'img_width'     => '140',
	 			'img_height'        => 30,
	 			'word'          => random_string('numeric', 6),
	 	);
	 
	 	$cap = create_captcha($vals);
	 
	 	return $cap;
	 }
	 
	 public function newUserRegistration()
	 {
	 	$this->load->model('artmodel');
	 	$this->load->library('session');
	 	$this->load->helper('captcha');
	 	$data = $this->setCaptcha();
	 	$displayData['data'] = $data;
	 	$uEmail = $this->artmodel->chkEmail($_POST);
	 	if($uEmail>0){
	 		$displayData['post'] = $_POST;
	 		$cUrl = $this->curURL();
	 		$displayData['curUrl'] = substr(strrchr($cUrl, "/"), 1);
	 		$displayData['regErrorMsg'] = 'Email Id already exists.';
                        $artistName = $this->artmodel->getAllArtistNane();
                        $displayData['artistName'] = $artistName;
                        $themeName = $this->artmodel->getAllTheme();
                        $displayData['themeName'] = $themeName;
                        $mediumName = $this->artmodel->getAllMedium();
                        $displayData['mediumName'] = $mediumName;
                        $catagoriesName = $this->artmodel->getAllCatagories();
                        $displayData['catagoriesName'] = $catagoriesName;
	 		$this->load->view('userRegister/joinus', $displayData);
	 	}else{
	 		$userId=$this->artmodel->userRegis($_POST);
	 		//var_dump($_POST);
		    
		    	
		   	$to = $_POST['Email'];
		 	$from ='from:"Artdex"<info@artdex.com>';
		 	$subject = "Please Verify Artdex Account Detail ";
		  	$headers = "MIME-Version: 1.0 \n";
		 	$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
		 	$headers .= "Return-Path: info@artdex.com\r\n";
		   	$message ="<a href='/mailToUser/user/register/$userId'>Validate your account</a>";
		   	$headers.=$from;
		   	mail($to,$subject,$message,$headers);
		   	$displayData['regMsg'] = 'Email Sent';
		   	$displayData['regMsg1'] = 'An email has been sent to you. Please click on the link to activate your account.';
                        $artistName = $this->artmodel->getAllArtistNane();
                        $displayData['artistName'] = $artistName;
                        $themeName = $this->artmodel->getAllTheme();
                        $displayData['themeName'] = $themeName;
                        $mediumName = $this->artmodel->getAllMedium();
                        $displayData['mediumName'] = $mediumName;
                        $catagoriesName = $this->artmodel->getAllCatagories();
                        $displayData['catagoriesName'] = $catagoriesName;
                        var_dump($to);
                        var_dump($subject);
                        var_dump($message);
                        var_dump($headers);
                       // var_dump($adveritsertID);
		   	$this->load->view('art_home',$displayData);
	 	}
	   }
	   
	 public function userLogin()
	 {
	 	$this->load->model('artmodel');
	 	$this->load->library('session');
	 	if(isset($_POST['User'])){
        	$username=$this->artmodel->userLogin($_POST);
        	$displayData['username'] = $username;
        
         if (isset($username[0]['email']) && $_POST['txtEmail']==$username[0]['email']){
        	$newdata = array(
        			'user_id'  => $username[0]['user_id'],
        			'name'=>$username[0]['name'],
        			'gender'=>$username[0]['gender'],
        			'pssword'=>$username[0]['pssword'],
            		'email'  => $username[0]['email'],
           			'logged_in' => TRUE
       	);
        	
        	if(isset($_POST['Login']))
        	{
        		if(isset($_POST['remember']))
        		{
        			$uId = $username[0]['user_id'];
        			$userid=$_POST['txtEmail'];
        			$password=$_POST['txtPass'];
        			$expire=time()+60*60*24*7;
        			setcookie('uId',$uId,$expire);
        			setcookie('userid',$userid,$expire);
        			setcookie('password',$password,$expire);
        		}
        	}
        	$this->session->set_userdata($newdata);
        	$sessionUserData = $this->session->all_userdata();
        }else {
        	$array_items = array('user_id' => '','name' => '','gender' => '','pssword' => 'pssword','email' => '', 'logged_in' => '');
        	$this->session->unset_userdata($array_items);
        }
        $sessionUserData = $this->session->all_userdata();
        if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
        	$displayData['sessionData']=$sessionUserData;
        	$displayData['name'] = $sessionUserData['name'];
        	$artistName = $this->artmodel->getAllArtistNane();
        	$displayData['artistName'] = $artistName;
        	$themeName = $this->artmodel->getAllTheme();
        	$displayData['themeName'] = $themeName;
        	$mediumName = $this->artmodel->getAllMedium();
        	$displayData['mediumName'] = $mediumName;
        	$catagoriesName = $this->artmodel->getAllCatagories();
        	$displayData['catagoriesName'] = $catagoriesName;
        
        	$this->load->view('art_home',$displayData);
        }
        else {
        	$displayData['errorMsg'] = 'Please enter correct Username/Password.';
        	$artistName = $this->artmodel->getAllArtistNane();
        	$displayData['artistName'] = $artistName;
        	$themeName = $this->artmodel->getAllTheme();
        	$displayData['themeName'] = $themeName;
        	$mediumName = $this->artmodel->getAllMedium();
        	$displayData['mediumName'] = $mediumName;
        	$catagoriesName = $this->artmodel->getAllCatagories();
        	$displayData['catagoriesName'] = $catagoriesName;
        	$this->load->view('art_home', $displayData);
        }
	 	}
	 	if(isset($_POST['Advertiser'])){
	 		$username=$this->artmodel->advertiserLogin($_POST);
	 		$displayData['username'] = $username;
	 		$ad_Id = $username[0]['ad_Id'];
	 		$advertiserDetail = $this->artmodel->getAdvertiserDetail($ad_Id);
	 		$displayData['advertiserDetail'] = $advertiserDetail;
	 		
	 		if (isset($username[0]['email']) && $_POST['txtEmail']==$username[0]['email']){
	 			$newdata = array(
	 					'user_id'  => $username[0]['ad_Id'],
	 					'name'=>$username[0]['fname'],
	 					'gender'=>$username[0]['gender'],
	 					'pssword'=>$username[0]['password'],
	 					'email'  => $username[0]['email'],
	 					'logged_in' => TRUE
	 			);
	 			 
	 			if(isset($_POST['Login']))
	 			{
	 				if(isset($_POST['remember']))
	 				{
	 					$uId = $username[0]['ad_Id'];
	 					$userid=$_POST['txtEmail'];
	 					$password=$_POST['txtPass'];
	 					$expire=time()+60*60*24*7;
	 					setcookie('uId',$uId,$expire);
	 					setcookie('userid',$userid,$expire);
	 					setcookie('password',$password,$expire);
	 				}
	 			}
	 			$this->session->set_userdata($newdata);
	 			$sessionUserData = $this->session->all_userdata();
	 		}else {
	 			$array_items = array('user_id' => '','name' => '','gender' => '','pssword' => '','email' => '', 'logged_in' => '');
	 			$this->session->unset_userdata($array_items);
	 		}
	 		$sessionUserData = $this->session->all_userdata();
	 		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
	 			$displayData['sessionData']=$sessionUserData;
	 			//var_dump($sessionUserData); die();
	 			$displayData['name'] = $sessionUserData['name'];
	 			
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 		
	 			$this->load->view('art_home',$displayData);
	 		}
	 		else {
	 			$displayData['errorMsg'] = 'Please enter correct Username/Password.';
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 			$this->load->view('art_home', $displayData);
	 		}
	 	}
	 	if(isset($_POST['Partner'])){
	 		$username=$this->artmodel->PartnerLogin($_POST);
	 		$displayData['username'] = $username;
	 	
	 		if (isset($username[0]['email']) && $_POST['txtEmail']==$username[0]['email']){
	 			$newdata = array(
	 					'user_id'  => $username[0]['partner_id'],
	 					'name'=>$username[0]['fname'],
	 					//'gender'=>$username[0]['gender'],
	 					'pssword'=>$username[0]['password'],
	 					'email'  => $username[0]['email'],
	 					'logged_in' => TRUE
	 			);
	 	
	 			if(isset($_POST['Login']))
	 			{
	 				if(isset($_POST['remember']))
	 				{
	 					$uId = $username[0]['partner_id'];
	 					$userid=$_POST['txtEmail'];
	 					$password=$_POST['txtPass'];
	 					$expire=time()+60*60*24*7;
	 					setcookie('uId',$uId,$expire);
	 					setcookie('userid',$userid,$expire);
	 					setcookie('password',$password,$expire);
	 				}
	 			}
	 			$this->session->set_userdata($newdata);
	 			$sessionUserData = $this->session->all_userdata();
	 		}else {
	 			$array_items = array('user_id' => '','name' => '','pssword' => '','email' => '', 'logged_in' => '');
	 			$this->session->unset_userdata($array_items);
	 		}
	 		$sessionUserData = $this->session->all_userdata();
	 		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
	 			//var_dump($sessionUserData); die();
	 			$displayData['sessionData']=$sessionUserData;
	 			$displayData['name'] = $sessionUserData['name'];
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 	
	 			$this->load->view('art_home',$displayData);
	 		}
	 		else {
	 			$displayData['errorMsg'] = 'Please enter correct Username/Password.';
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 			$this->load->view('art_home', $displayData);
	 		}
	 	}
	 	if(isset($_POST['Artist'])){
	 		$username=$this->artmodel->artistLogin($_POST);
	 		$displayData['username'] = $username;
	 	
	 		if (isset($username[0]['email']) && $_POST['txtEmail']==$username[0]['email']){
	 			$newdata = array(
	 					'user_id'  => $username[0]['artist_id'],
	 					'name'=>$username[0]['fname'],
	 					'gender'=>$username[0]['gender'],
	 					'pssword'=>$username[0]['password'],
	 					'email'  => $username[0]['email'],
	 					'logged_in' => TRUE
	 			);
	 	
	 			if(isset($_POST['Login']))
	 			{
	 				if(isset($_POST['remember']))
	 				{
	 					$uId = $username[0]['artist_id'];
	 					$userid=$_POST['txtEmail'];
	 					$password=$_POST['txtPass'];
	 					$expire=time()+60*60*24*7;
	 					setcookie('uId',$uId,$expire);
	 					setcookie('userid',$userid,$expire);
	 					setcookie('password',$password,$expire);
	 				}
	 			}
	 			$this->session->set_userdata($newdata);
	 			$sessionUserData = $this->session->all_userdata();
	 		}else {
	 			$array_items = array('user_id' => '','name' => '','gender' => '','pssword' => '','email' => '', 'logged_in' => '');
	 			$this->session->unset_userdata($array_items);
	 		}
	 		$sessionUserData = $this->session->all_userdata();
	 		if(isset($sessionUserData['logged_in']) && $sessionUserData['logged_in']){
	 			$displayData['sessionData']=$sessionUserData;
	 			//var_dump($sessionUserData); die();
	 			$displayData['name'] = $sessionUserData['name'];
	 		 	
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 	
	 			$this->load->view('art_home',$displayData);
	 		}
	 		else {
	 			$displayData['errorMsg'] = 'Please enter correct Username/Password.';
	 			$artistName = $this->artmodel->getAllArtistNane();
	 			$displayData['artistName'] = $artistName;
	 			$themeName = $this->artmodel->getAllTheme();
	 			$displayData['themeName'] = $themeName;
	 			$mediumName = $this->artmodel->getAllMedium();
	 			$displayData['mediumName'] = $mediumName;
	 			$catagoriesName = $this->artmodel->getAllCatagories();
	 			$displayData['catagoriesName'] = $catagoriesName;
	 			$this->load->view('art_home', $displayData);
	 		}
	 	}
	 	
        }
        
        public function userLogout()
        {
        	$this->load->library('session');
        	$this->load->model('artmodel');
        	$array_items = array('user_id' => '','name' => '','gender' => '','pssword' => 'pssword','email' => '', 'logged_in' => '');
        	$this->session->unset_userdata($array_items);
        	$expire=time()-60*60*24*7;
        	setcookie('uId','',$expire);
        	setcookie('userid','',$expire);
        	setcookie('password','',$expire);
        	$displayData['errorMsg'] = 'You have been successfully logged out.';
                $artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
        	$this->load->view('art_home', $displayData);
        }
        
        public function mailToUser($decoded)
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
          	$this->artmodel->mailUpdate($decoded);
        	$this->load->helper('captcha');
        	$data = $this->setCaptcha();
        	$displayData['data'] = $data;
                $artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
                $this->load->view('userRegister/joinus',$displayData);
        }
        public function userForgetPassword()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	$artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
        	//$this->artmodel->mailUpdate($decoded);
        	$this->load->view('userRegister/userForgetPassword',$displayData);
        }
        
        
        
        public function forgetPassword()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
            $forgetPasswordId=$this->artmodel->forgetPassword($_POST);
            $displayData['forgetPasswordId'] = $forgetPasswordId;
            $id=$forgetPasswordId[0]['user_id'];
            $to = $_POST['forgrtmail'];
            $from ='from:"Artdex"<info@artdex.com>';
            $subject = "Please Click On The Link To Forget Your Password";
            $headers = "MIME-Version: 1.0 \n";
            $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
            $headers .= "Return-Path: info@artdex.com\r\n";
            $message ="<a href='/mailForgetPassword/$id'>Click On Password</a>";
            $headers.=$from;
            mail($to,$subject,$message,$headers);
          //  $this->load->view('art_home');
            $artistName = $this->artmodel->getAllArtistNane();
            $displayData['artistName'] = $artistName;
            $themeName = $this->artmodel->getAllTheme();
            $displayData['themeName'] = $themeName;
            $mediumName = $this->artmodel->getAllMedium();
            $displayData['mediumName'] = $mediumName;
            $catagoriesName = $this->artmodel->getAllCatagories();
            $displayData['catagoriesName'] = $catagoriesName;
            $this->load->view('userRegister/joinus',$displayData);
        }
        public function mailForgetPassword($cId)
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	$displayData['cId'] = $cId;
                $artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
           	$this->load->view('userRegister/forgetPassword',$displayData);
        }
        public function UpdatePassword()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
          	$this->artmodel->UpdateToPassword($_POST);
                $artistName = $this->artmodel->getAllArtistNane();
                $displayData['artistName'] = $artistName;
                $themeName = $this->artmodel->getAllTheme();
                $displayData['themeName'] = $themeName;
                $mediumName = $this->artmodel->getAllMedium();
                $displayData['mediumName'] = $mediumName;
                $catagoriesName = $this->artmodel->getAllCatagories();
                $displayData['catagoriesName'] = $catagoriesName;
        	$this->load->view('userRegister/joinus',$displayData);
        }
        
        //////////advertiser-----------managment------------->
        public function advertiserContinue()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
          	$displayData['sessionData'] = $sessionData;
        	$displayData['post'] = $_POST;
            $artistName = $this->artmodel->getAllArtistNane();
            $displayData['artistName'] = $artistName;
            $themeName = $this->artmodel->getAllTheme();
            $displayData['themeName'] = $themeName;
            $mediumName = $this->artmodel->getAllMedium();
            $displayData['mediumName'] = $mediumName;
            $catagoriesName = $this->artmodel->getAllCatagories();
            $displayData['catagoriesName'] = $catagoriesName;
            $Country= $this->artmodel->getAllCountry();
            $displayData['Country']=$Country;
            // var_dump($Country);
        	$this->load->view('userRegister/advertiserContinue',$displayData);
        }
        public function insertAdvertise()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	$displayData['post'] = $_POST;
        	$artistName = $this->artmodel->getAllArtistNane();
        	$displayData['artistName'] = $artistName;
        	$themeName = $this->artmodel->getAllTheme();
        	$displayData['themeName'] = $themeName;
        	$mediumName = $this->artmodel->getAllMedium();
        	$displayData['mediumName'] = $mediumName;
        	$catagoriesName = $this->artmodel->getAllCatagories();
        	$displayData['catagoriesName'] = $catagoriesName;
        	$adveritsertID= $this->artmodel->insertAdvertiser($_POST);
        	$to = $_POST['Email'];
        	$from ='from:"Artdex"<info@artdex.com>';
        	$subject = "Please Verify Artdex Account Detail ";
        	$headers = "MIME-Version: 1.0 \n";
        	$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
        	$headers .= "Return-Path: info@artdex.com\r\n";
        	$message ="<a href='/mailtoAdvertiser/$adveritsertID'>Validate your account</a>";
        	$headers.=$from;
        	mail($to,$subject,$message,$headers);
        	$displayData['regMsg'] = 'Email Sent';
        	$displayData['regMsg1'] = 'An email has been sent to you. Please click on the link to activate your account.';
        	var_dump($to);
        	var_dump($subject);
        	var_dump($message);
        	var_dump($headers);
        	var_dump($adveritsertID);
        	$this->load->view('art_home',$displayData);
        }
        public function mailtoAdvertiser($decoded)
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	$this->artmodel->updateMailAdvertise($decoded);
        	$artistName = $this->artmodel->getAllArtistNane();
        	$displayData['artistName'] = $artistName;
        	$themeName = $this->artmodel->getAllTheme();
        	$displayData['themeName'] = $themeName;
        	$mediumName = $this->artmodel->getAllMedium();
        	$displayData['mediumName'] = $mediumName;
        	$catagoriesName = $this->artmodel->getAllCatagories();
        	$displayData['catagoriesName'] = $catagoriesName;
        	$this->load->view('art_home',$displayData);
        }
        public function advertiserLink()
        {
	        $this->load->model('artmodel');
			$this->load->library('session');
	        $sessionData = $this->session->all_userdata();
			$displayData['sessionData'] = $sessionData;
	        if (isset($sessionData['logged_in']) && $sessionData['logged_in']) {
	         $displayData['name'] = $sessionData['name'];  
	       
	        }
	                $artistName = $this->artmodel->getAllArtistNane();
	                $displayData['artistName'] = $artistName;
	                $themeName = $this->artmodel->getAllTheme();
	                $displayData['themeName'] = $themeName;
	                $mediumName = $this->artmodel->getAllMedium();
	                $displayData['mediumName'] = $mediumName;
	                $catagoriesName = $this->artmodel->getAllCatagories();
	                $displayData['catagoriesName'] = $catagoriesName;
		  	$this->load->view('advertiser/post_free_ads', $displayData);
        }
        public function loadstate($catId)
        {
        	$this->load->model('artmodel');
        	$state= $this->artmodel->selecStateById($catId);
        	$displayData['state'] = $state;
        	$displayData['catId'] = $catId;
        	//var_dump($catId); die();
        	$this->load->view('advertiser/stateSelect',$displayData);
        }
        public function loadCity($catId)
        {
        	$this->load->model('artmodel');
        	$city= $this->artmodel->selecCityById($catId);
        	$displayData['city'] = $city;
        	$displayData['catId'] = $catId;
        	
        	$this->load->view('advertiser/citySelect',$displayData);
        }
        public function InsertAdvertisment()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	if (isset($sessionData['logged_in']) && $sessionData['logged_in']) {
        		$displayData['name'] = $sessionData['name'];
        		 
        	}
            $displayData['post'] = $_POST;
        	$_POST['file'] = $_FILES;
            $adsID = $this->artmodel->InsertAdvertisment($_POST);
            $advertisment = $this->artmodel->AdvertismentDetail($adsID);
            $displayData['advertisment'] = $advertisment;
            $this->load->view('advertiser/advertismentview',$displayData);
        }
        public function backAdvertisment()
        {
        	$this->load->model('artmodel');
        	$this->load->library('session');
        	$sessionData = $this->session->all_userdata();
        	$displayData['sessionData'] = $sessionData;
        	
           
            $this->load->view('advertiser/art_advertiser',$displayData);
        }
        
       ///////--------cms managment---------------> 
        public function aboutUs() {
        $this->load->model('artmodel');
        $artistName = $this->artmodel->getAllArtistNane();
        $displayData['artistName'] = $artistName;
        $themeName = $this->artmodel->getAllTheme();
        $displayData['themeName'] = $themeName;
        $mediumName = $this->artmodel->getAllMedium();
        $displayData['mediumName'] = $mediumName;
        $catagoriesName = $this->artmodel->getAllCatagories();
        $displayData['catagoriesName'] = $catagoriesName;
        $getData = $this->artmodel->getAllCms('About Us');
        $displayData['getData'] = $getData;
        //var_dump($displayData);

        $this->load->view('cmsPage', $displayData);
    }

    public function contactUs() {
        $this->load->model('artmodel');
        $artistName = $this->artmodel->getAllArtistNane();
        $displayData['artistName'] = $artistName;
        $themeName = $this->artmodel->getAllTheme();
        $displayData['themeName'] = $themeName;
        $mediumName = $this->artmodel->getAllMedium();
        $displayData['mediumName'] = $mediumName;
        $catagoriesName = $this->artmodel->getAllCatagories();
        $displayData['catagoriesName'] = $catagoriesName;
        $getData = $this->artmodel->getAllCms('Contact Us');
        $displayData['getData'] = $getData;
        // var_dump($displayData);

        $this->load->view('cmsPage', $displayData);
    }

    public function disclaimer() {
        $this->load->model('artmodel');
        $artistName = $this->artmodel->getAllArtistNane();
        $displayData['artistName'] = $artistName;
        $themeName = $this->artmodel->getAllTheme();
        $displayData['themeName'] = $themeName;
        $mediumName = $this->artmodel->getAllMedium();
        $displayData['mediumName'] = $mediumName;
        $catagoriesName = $this->artmodel->getAllCatagories();
        $displayData['catagoriesName'] = $catagoriesName;
        $getData = $this->artmodel->getAllCms('Disclaimer');
        $displayData['getData'] = $getData;
        //var_dump($displayData);

        $this->load->view('cmsPage', $displayData);
    }

    public function privacyPolicy() {
        $this->load->model('artmodel');
        $artistName = $this->artmodel->getAllArtistNane();
        $displayData['artistName'] = $artistName;
        $themeName = $this->artmodel->getAllTheme();
        $displayData['themeName'] = $themeName;
        $mediumName = $this->artmodel->getAllMedium();
        $displayData['mediumName'] = $mediumName;
        $catagoriesName = $this->artmodel->getAllCatagories();
        $displayData['catagoriesName'] = $catagoriesName;
        $getData = $this->artmodel->getAllCms('Privacy Policy');
        $displayData['getData'] = $getData;
        //var_dump($displayData);

        $this->load->view('cmsPage', $displayData);
    }
    
    public function resellerPage(){
        $this->load->model('artmodel');
        $artistName = $this->artmodel->getAllArtistNane();
        $displayData['artistName'] = $artistName;
        $themeName = $this->artmodel->getAllTheme();
        $displayData['themeName'] = $themeName;
        $mediumName = $this->artmodel->getAllMedium();
        $displayData['mediumName'] = $mediumName;
        $catagoriesName = $this->artmodel->getAllCatagories();
        $displayData['catagoriesName'] = $catagoriesName;
        $Country = $this->artmodel->getCountry();
        $displayData['Country'] = $Country;
       // var_dump($Country);
        $this->load->view('reseller', $displayData);
        
    }
    
    
    ///----------Artist Managment---------------
   public function insertArtist()
    {
    	$this->load->model('artmodel');
    	$this->load->library('session');
    	$sessionData = $this->session->all_userdata();
    	$displayData['sessionData'] = $sessionData;
    	$displayData['post'] = $_POST;
    	$this->load->helper('captcha');
    	$data = $this->setCaptcha();
    	$displayData['data'] = $data;
    	$uEmail = $this->artmodel->chkEmailArtist($_POST);
    	if($uEmail>0){
    		$displayData['post'] = $_POST;
    		$cUrl = $this->curURL();
    		$displayData['curUrl'] = substr(strrchr($cUrl, "/"), 1);
    		$displayData['regErrorMsg'] = 'Email Id already exists.';
    		$artistName = $this->artmodel->getAllArtistNane();
    		$displayData['artistName'] = $artistName;
    		$themeName = $this->artmodel->getAllTheme();
    		$displayData['themeName'] = $themeName;
    		$mediumName = $this->artmodel->getAllMedium();
    		$displayData['mediumName'] = $mediumName;
    		$catagoriesName = $this->artmodel->getAllCatagories();
    		$displayData['catagoriesName'] = $catagoriesName;
    		$this->load->view('userRegister/joinus', $displayData);
    	}else{
    	$artistName = $this->artmodel->getAllArtistNane();
    	$displayData['artistName'] = $artistName;
    	$themeName = $this->artmodel->getAllTheme();
    	$displayData['themeName'] = $themeName;
    	$mediumName = $this->artmodel->getAllMedium();
    	$displayData['mediumName'] = $mediumName;
    	$catagoriesName = $this->artmodel->getAllCatagories();
    	$displayData['catagoriesName'] = $catagoriesName;
    	$adveritsertID= $this->artmodel->artistInsert($_POST);
    	//var_dump($_POST); die();
    	$to = $_POST['Email'];
    	$from ='from:"Artdex"<info@artdex.com>';
    	$subject = "Please Verify Artdex Account Detail ";
    	$headers = "MIME-Version: 1.0 \n";
    	$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
    	$headers .= "Return-Path: info@artdex.com\r\n";
    	$message ="<a href='/maiToArtist/sessionid/djhuhfv65676/$adveritsertID/2343//Artist'>Validate your account</a>";
    	$headers.=$from;
    	mail($to,$subject,$message,$headers);
    	$displayData['regMsg'] = 'Email Sent';
    	$displayData['regMsg1'] = 'An email has been sent to you. Please click on the link to activate your account.';
    	var_dump($to);
    	var_dump($subject);
    	var_dump($message);
    	var_dump($headers);
    	var_dump($adveritsertID);
    	$this->load->view('art_home',$displayData);
    	}
     }
    public function maiToArtist($Aid)
    {
    	
    	$this->load->model('artmodel');
    	$this->load->library('session');
    	$sessionData = $this->session->all_userdata();
    	$displayData['sessionData'] = $sessionData;
    	$this->load->helper('captcha');
    	$data = $this->setCaptcha();
    	$displayData['data'] = $data;
    	$this->artmodel->UpdateartistStatus($Aid);
    	$artistName = $this->artmodel->getAllArtistNane();
    	$displayData['artistName'] = $artistName;
    	$themeName = $this->artmodel->getAllTheme();
    	$displayData['themeName'] = $themeName;
    	$mediumName = $this->artmodel->getAllMedium();
    	$displayData['mediumName'] = $mediumName;
    	$catagoriesName = $this->artmodel->getAllCatagories();
    	$displayData['catagoriesName'] = $catagoriesName;
    	$this->load->view('art_home',$displayData);
    	}
        
        function curURL() {
        	$pageURL = 'http';
        	if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
        		$pageURL .= "s";
        	}
        	$pageURL .= "://";
        	if ($_SERVER["SERVER_PORT"] != "80") {
        		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
        	} else {
        		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
        	}
        	return $pageURL;
        }
}